<template>
	<view class="content">
		<view class="nav">
			<view class="nav_item1" @tap="navClick(0)">
				<view class="nav_title">{{typeName}}</view>
				<i class="iconfont iconjiantou nav_icon "></i>
			</view>
			<view class="nav_item1" @tap="navClick(1)">
				<view class="nav_title">{{fromName}}</view>
				<i class="iconfont iconjiantou nav_icon"></i>
			</view>
			<view class="nav_item2" @tap="navClick(2)">
				<view class="nav_title">{{methodName}}-{{subName}}</view>
				<i class="iconfont iconjiantou nav_icon"></i>
			</view>
		</view>
		<!-- 题型 -->
		<scroll-view scroll-y="true" class="nav_type" v-if="typeIf" @touchmove.stop.prevent="moveHandle" @tap="closeAll">
			<view class="type_item" v-for="(item,index) in typeList" :key="index" @tap="itemClick(item.question_type_name,item.question_type_id,index,0)">
				<text :class="[index == itemIndex1 ? 'name_active' : '']">{{item.question_type_name}}</text>
				<i v-if="index == itemIndex1" class="iconfont iconduigou"></i>
			</view>
		</scroll-view>
		<!-- 来源 -->
		<view class="nav_type" v-if="fromIf" @touchmove.stop.prevent="moveHandle" @tap="closeAll">
			<view class="type_item" v-for="(item,index) in fromList" :key="index" @tap="itemClick(item.title,item.source_type,index,1)">
				<text :class="[index == itemIndex2 ? 'name_active' : '']">{{item.title}}</text>
				<i v-if="index == itemIndex2" class="iconfont iconduigou"></i>
			</view>
		</view>
		<!-- 方式-科目 -->
		<view class="nav_type" v-if="methodIf" @touchmove.stop.prevent="moveHandle" @tap="closeAll">
			<view class="type_item2">
				<view class="type_left">
					<view class="left_name" :class="[index == itemIndex3 ? 'type_active' : '']" v-for="(item,index) in methodList"
					 :key="index" @tap="itemClick(item.name,item.value,index,2)">
						<text>{{item.name}}</text>
					</view>
				</view>
				<scroll-view class="type_right" scroll-y="true">
					<view class="right-subject" v-for="(item1,index1) in subList" :key="index1" @tap="itemClick(item1.subject_name,item1.sid,index1,3,item1.textbook)">
						<text :class="[index1 == itemIndex4 ? 'name_active' : '']">{{item1.subject_name}}</text>
						<i v-if="index1 == itemIndex4" class="iconfont iconduigou"></i>
					</view>
				</scroll-view>
			</view>
		</view>
		<view class="list" v-if="datas.length > 0">
			<view class="list_item" v-for="(item,index) in datas" :key="index">
				<view v-if="item.source_type==2" class="question_classify">自评</view>
				<view v-if="item.source_type==3" class="question_classify">同步</view>
				<view v-if="item.source_type==4" class="question_classify">趣练</view>
				<view v-if="item.source_type==5" class="question_classify">智测</view>
				<view class="title">
					<view v-html="item.question_title"></view>
				</view>
				<view class="time">
					<view class="left">
						{{item.update_time}}
						<text>错{{item.errors_num}}次</text>
					</view>
					<view class="right" @tap="detail(item.intelligent_id)">详情</view>
				</view>
			</view>
			<uni-load-more v-if="datas.length >= 6" :status="status" :content-text="contentText" />
		</view>
		
		<view class="list" v-if="sectionList.length > 0 ">
			<!-- 上册第x单元 -->
			<view class="list_item" v-for="(item,index) in sectionList" :key="index" @tap="getfzid(item.zid,index)">
				<view class="zj-item">
					<view class="zj-item-name" v-html="item.section_name"></view>
					<i class="iconfont icon-fanhui" :class="item.is_show ? 'rotate' : ''"></i>
				</view>
				<!-- 对应单元下拉弹窗章节 -->
				<view class="dialog" v-show="item.is_show">
					<block v-if="zid_list[item.zid] && zid_list[item.zid].length">
						<view class="dialog-item" v-for="(item1,index1) in zid_list[item.zid]" :key="index1" @tap="changeZj(item1.section_name,item1.zid,item.section_name,item1.errors_num,item1.total)">
							<view class="dialog-item-left" v-html="item1.section_name"></view>
							<view class="dialog-item-right">
								<view class="error1" v-if="item1.errors_num > 10"><text>错{{item1.errors_num}}次</text> 共{{item1.total}}题</view>
								<view class="error2" v-if="item1.errors_num < 10"><text>错{{item1.errors_num}}次</text> 共{{item1.total}}题</view>
								<i class="iconfont icon-fanhui"></i>
							</view>
						</view>
					</block>
					<view class="dialog-item" style="color: #999;" v-if="zid_list[item.zid] && zid_list[item.zid].length === 0">暂无错题</view>
				</view>
			</view>
			<uni-load-more v-if="sectionList.length >= 10" :status="status" :content-text="contentText" />
		</view>
		
		<view class="none" v-if="datas.length == 0 && sectionList.length == 0 && !is_show">没有数据</view>
		
		<!-- 年级弹窗 -->
		<block v-if="is_classtap">
			<view class="wrap">
				<view class="wrap-grade">
					<view :class="['grade-item', index == class_index ? 'grade_avctive' : '']" v-for='(item,index) in grade_list' :key='index' @tap="selectClass(index)">
						{{item.grade_name}}<text :class="index == class_index ? 'iconfont iconduigou dagou': ''"></text>
					</view>
				</view>
			</view>
			<view class="wrap-background" @tap='is_classtap = false' @touchmove.stop.prevent='moveHandle'></view>
		</block>
		
	</view>
</template>

<script>
	import util from '../../common/util.js';
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	var _this = ''
	export default {
		components: {
			uniLoadMore
		},
		data() {
			_this = this;
			return {
				typeName: '题型',
				typeList: [],
				typeIf: false,
				fromName: '来源',
				fromList: [{
						source_type: '',
						title: '全部'
					},
					{
						source_type: 3,
						title: '同步'
					},
					{
						source_type: 4,
						title: '趣练'
					},
					{
						source_type: 2,
						title: '自评'
					},
					{
						source_type: 5,
						title: '智测'
					}
				],
				fromIf: false,
				methodName: '按时间',
				methodList: [{
						value: 1,
						name: '按时间'
					},
					{
						value: 2,
						name: '按章节'
					},
					{
						value: 3,
						name: '曾经的错题'
					}
				],
				methodIf: false,
				subName: '全部',
				subList: [],
				itemIndex1: 0,
				itemIndex2: 0,
				itemIndex3: 0,
				itemIndex4: 0,
				status: 'more',
				reload: true,
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多',
					contentnot: "没数据"
				},
				datas: [],
				page: 1,
				pages: 1, //章节列表page
				sectionList: [], //章节列表
				fList: [], // 子章节列表
				source_type: '', //选中的来源数值 1为课后作业,2为自评，3为同步，4为趣练，5为智测,6为课前作业，7为随堂练习，8为班级测验
				question_typeid: '', //题型Id
				sid: '', //选中的科目Id
				textboox: '', //选中的科目教材版本
				state: 1,
				switch: 0,
				groupid: '',
				lists_type: 1, //1普通错题本，2班级错题本
				student_id: '',
				grade: uni.getStorageSync('currentChild').grade,

				zid_list: {}, // 存储所有章节列表，以便后续操作获取
				is_show: true, // 控制进来时不要显示‘暂无数据’
				show_loading: true, // false表示下拉时不要有动画
				
				is_classtap: false, // 年级的弹窗显示/隐藏
				grade_list: util.getStage(999),
				class_index: 0, // 选择年级的索引值
				class_title: '', // 存储选择后的年级名称
			}
		},
		// 上拉刷新
		onPullDownRefresh() {
			this.reload = true;
			this.page = 1;
			this.getlist();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		// 下拉刷新
		onReachBottom() {
			this.status = 'loading';
			if (this.itemIndex3 == 1) {
				this.pages = this.pages + 1;
				var _this = this;
				setTimeout(function() {
					_this.getZjList();
				}, 500);
			} else {
				this.page = this.page + 1;
				var _this = this;
				setTimeout(function() {
					_this.getlist();
				}, 500);
			}
			// 下拉禁止有Loading...
			this.show_loading = false 
		},
		
		// 导航栏年级弹窗事件
		onNavigationBarButtonTap() {
			// 控制显示/隐藏
			this.is_classtap = !this.is_classtap
			// 点击年级时，把所有的筛选弹窗隐藏掉
			this.typeIf = false
			this.fromIf = false
			this.methodIf = false
		},
		
		onLoad(e) {
			// 获取孩子ID ，以便后续请求所需
			this.student_id = e.student_id;
			if (e.groupid != null) {
				this.groupid = e.groupid;
				this.fromList = [{
							source_type: '',
							title: '全部'
						},
						{
							source_type: 6,
							title: '课前作业'
						},
						{
							source_type: 7,
							title: '随堂练习'
						},
						{
							source_type: 1,
							title: '课后作业'
						},
						{
							source_type: 8,
							title: '班级测验'
						}
					],
					uni.setNavigationBarTitle({
						title: '班级智题本'
					})
			}
			// TODO： 这里获取的年级不是最新的，一旦学生端改变了年级，这里的年级传递过来的还是之前的年级
			// this.grade = e.grade;
			
			// 实时更获取孩子年级
			this.$zapi.apiPost('user/currency.Parents/childlist').then(res => {
				// this.grade = res.data.data[0].grade 
				
				// 一进来时默认显示用户当前年级
				// #ifdef APP-PLUS  | MP-WEIXIN
				let grade_index = Number(this.grade)
				
				var webView = this.$mp.page.$getAppWebview();
				if (grade_index) {
					webView.setTitleNViewButtonStyle(0, {
						text: this.grade_list[grade_index - 1].grade_name
					});
					// 默认进来时，年级的激活样式索引值也要跟随着默认年级
					this.class_index = grade_index - 1
				}
				// #endif
				
				// 获取孩子年级后，再去触发相关请求函数。
				// this.getlist();
			})
			this.getType();
			this.getSub();
		},
		// onShow() {
		// 	this.reload = true
		// 	this.page = 1
		// 	this.datas = []
		// 	this.getlist()
		// },
		methods: {
			// 选择班级事件
			selectClass(index) {
				this.class_index = index
				// 选择后取消班级弹窗
				this.is_classtap = false
				// 将选择的班级作为默认值
				this.class_title = this.grade_list[index].grade_name
				
				// 选择相应的年级并赋值到导航栏中
				// #ifdef APP-PLUS  | MP-WEIXIN
				var webView = this.$mp.page.$getAppWebview();
					webView.setTitleNViewButtonStyle(0, {
						text: this.class_title,
					});
				// #endif
				
				// 存储选择后的年级，作为选择班级时请求所需参数
				this.grade = this.grade_list[index].grade
				
				// 选择班级时触发相关数据
				// 有点击【按章节】就触发函数
				if(this.switch == 1) { 
					this.getSub()
					this.getClassZjList()
				} else {
					// 否则就请求其他筛选的
					this.getClasslist()
				}
			},
			
			/* 题型 */
			getType() {
				this.$zapi.apiPost('user/currency.basic/questionTypeList').then(res => {
					if (res.data.code == 200) {
						this.typeList = res.data.data;
						this.typeList.unshift({
							question_type_id: '',
							question_type_name: '全部'
						});
					}
				});
			},
			/* 科目 */
			getSub() {
				this.$zapi.apiPost('user/subject.Lists/subjectLists', {
					student_id: this.student_id
				}).then(res => {
					if (res.data.code == 200) {
						var data = res.data.data;
						var length = data.length;
						for (var i = 0; i < length; i++) {
							data[i]['subject_name'] = data[i]['subject_name'].replace(/\s+/g, "");
						}
						this.subList = data;
						if (this.itemIndex3 != 1) {
							this.subList.unshift({
								sid: '',
								subject_name: '全部'
							});
						}
						this.itemClick(this.subList[0].subject_name, this.subList[0].sid, 0, 3, this.subList[0].textbook);
					}
				});
			},

			getlist: function() {
				var data = {
					page: this.page,
					pagesize: 8,
					lists_type: this.lists_type,
					state: this.state,
					student_id: this.student_id,
					grade: this.grade
				};
				if (this.groupid != '') {
					data.lists_type = 2;
					data.groupid = this.groupid;
				}
				if (this.source_type != '') {
					data.source_type = this.source_type;
				}
				if (this.question_typeid != '') {
					data.question_typeid = this.question_typeid;
				}
				if (this.sid != '') {
					data.subjectid = this.sid;
				}
				
				if (this.show_loading) {
					uni.showLoading({
						title: '正在加载中...'
					})
				}
				
				this.$zapi.apiPost('user/intelligent.users/intelligentLists', data).then(res => {
					if (res.data.code == 200 &&　res.data.data.data.length > 0) {
						var data = res.data.data.data;
						var question_ids_string = res.data.data.question_ids_string;
						this.loaddata(data, question_ids_string);
					} else {
						this.is_show = false
						if (this.show_loading) uni.hideLoading()
						if (this.reload) {
							this.datas = [];
						} else {
							this.status = 'noMore';
						}
					}
				});
			},
			// PS:由于底部加载的时候会用到getlist函数，这里重新声明一个函数来给选择年级进行请求数据，以免冲突
			getClasslist() {
				// 重新选择年级时，应该把之前的数据都给清空了
				this.datas = []
				this.page = 1
				var data = {
					page: 1, // 选择年级的时候，page页数应该为1 重新开始才对。否则会累加之前的页数去进行请求，导致请求不到。
					pagesize: 5,
					lists_type: this.lists_type,
					state: this.state,
					grade: this.grade,
					student_id: this.student_id,
				};
				if(this.groupid != '') {
					data.lists_type = 2;
					data.groupid = this.groupid;
				}
				if (this.source_type != '') {
					data.source_type = this.source_type;
				}
				if (this.question_typeid != '') {
					data.question_typeid = this.question_typeid;
				}
				if(this.sid != '') {
					data.subjectid = this.sid;
				}
				
				if (this.show_loading) {
					uni.showLoading({
						title: '正在加载中...'
					})
				}
				
				this.$zapi.apiPost('user/intelligent.users/intelligentLists', data).then(res => {
					if (res.data.code == 200) {
						var data = res.data.data.data;
						var question_ids_string = res.data.data.question_ids_string;
						this.loaddata(data, question_ids_string);
						// 关闭加载动画
						uni.hideLoading()
					} else {
						this.is_show = false
						if (this.show_loading) uni.hideLoading()
						// 选择年级没有数据后， 应该清空原来的数据
						this.datas = [];
					}
				});
			},
			
			loaddata: function(list, question_ids_string) {
				this.$zapi.apiPost('user/question.Lists/questionList', {
					question_id: question_ids_string,
					is_get_answer: 2,
					is_out_html: 1
				}).then(res => {
					if (res.data.code == 200) {
						var dataList = res.data.data.data;
						for(var i = 0; i < dataList.length; i++) {
							if(!dataList[i].answer_list) {
								dataList[i].answer_list = [];
							}
						}
						util.latex_reques(dataList, 'question_title'); //解析 试题标题 latex 公式转换
						util.latex_reques(dataList, 'question_analysis'); //解析 试题解析 latex 公式转换
						util.latex_answer(dataList, 'answer_list'); //解析答案选项 latex 公式转换
						for (let i = 0; i < dataList.length; i++) {
							var arr = [];
							for (let j = 0; j < list.length; j++) {
								if (dataList[i].question_id == list[j].question_id) {
									var obj = {};
									dataList[i].is_favorite = list[j].is_favorite;
									obj.user_text_answer = list[j].user_text_answer;
									obj.question_answer_id = list[j].question_answer_id;
									arr.push(obj);
								}
							}
							dataList[i].interest_lists_log = arr;
						}

						var da = util.getAnalysis(dataList);
						this.datas = this.reload ? da : this.datas.concat(da);
						for (let i = 0; i < this.datas.length; i++) {
							for (let j = 0; j < list.length; j++) {
								if (this.datas[i].question_id == list[j].question_id) {
									this.datas[i].source_type = list[j].source_type;
									var time = list[j].update_time;
									this.datas[i].update_time = util.getBriefTime(time);
									this.datas[i].errors_num = list[j].errors_num;
									this.datas[i].intelligent_id = list[j].intelligent_id;
								}
							}
						}
						if (this.show_loading) uni.hideLoading()
						this.reload = false;
						this.status = 'more';
					} else {
						if (this.show_loading) uni.hideLoading()
						this.is_show = false
					}
				});
			},
			
			// 获取单元
			getZjList() {
				// 存储当前阶段
				var education = '';
				// 根据年级判断来赋值不同的阶段
				if (this.grade < 7) {
					education = 6
				} else if (this.grade > 6 && this.grade < 10) {
					education = 9
				} else if (this.grade > 9) {
					education = 12
				}
				// 章节列表所需参数
				var data = {
					education: education,
					grade: this.grade,
					type: 1,
					sid: this.sid,
					textbook: this.textboox,
					page: this.pages,
					pagesize: 12
				}
				// 开始请求[章节列表]，如第x单元
				this.$zapi.apiPost('user/subject.Lists/sectionList', data).then(res => {
					if (res.data.code == 200 && res.data.data.data.length > 0) {
						var list = res.data.data.data;
						// 累加单元列表，因为有下拉刷新，因此需要累加
						this.sectionList = this.reload ? list : this.sectionList.concat(list);
						// 默认给每个单元列表添加一个is_show为false，用来弹窗子章节列表用的
						for (let i = 0; i < this.sectionList.length; i++) {
							this.sectionList[i].is_show = false;
						}
						// 表示还有数据，可以继续加载
						this.reload = false;
						this.status = 'more';
					} else {
						this.is_show = false;
						// 表示没有数据
						if (this.reload) {
							this.sectionList = [];
						} else {
							this.status = 'noMore';
						}
					}
				})
			},
			
			// PS: 由于底部加载要触发请求单元，因此选择年级时不与底部加载单元请求函数冲突，重新申明一个
			getClassZjList() {
				// 存储当前阶段
				var education = '';
				// 根据年级判断来赋值不同的阶段
				if (this.grade < 7) {
					education = 6
				} else if (this.grade > 6 && this.grade < 10) {
					education = 9
				} else if (this.grade > 9) {
					education = 12
				}
				// 章节列表所需参数
				var data = {
					education: education,
					grade: this.grade,
					type: 1,
					sid: this.sid,
					textbook: this.textboox,
					page: this.pages,
					pagesize: 10
				}
				// 开始请求[章节列表]，如第x单元
				this.$zapi.apiPost('user/subject.Lists/sectionList', data).then(res => {
					if (res.data.code == 200) {
						var list = res.data.data.data;
						// 累加单元列表，因为有下拉刷新，因此需要累加
						this.sectionList = this.reload ? list : this.sectionList.concat(list);
						// 默认给每个单元列表添加一个is_show为false，用来弹窗子章节列表用的
						for (let i = 0; i < this.sectionList.length; i++) {
							this.sectionList[i].is_show = false;
						}
						// 表示还有数据，可以继续加载
						this.reload = false;
						this.status = 'more';
					} else {
						// 表示没有数据
						this.sectionList = []
						// 拿不到数据进行提示
						this.is_show = false
					}
				})
			},

			// 获取弹出子章节列表数据
			getfzid(zid, index) {
				// 用来控制显示/隐藏 弹窗子章节列表
				this.sectionList[index].is_show = !this.sectionList[index].is_show;
				this.$forceUpdate();
				
				// 根据年级判断来赋值不同的阶段
				var education = '';
				if (this.grade < 7) {
					education = 6
				} else if (this.grade > 6 && this.grade < 10) {
					education = 9
				} else if (this.grade > 9) {
					education = 12
				}
				
				// 请求账[章节知识点列表]所需参数
				var data = {
					education: education,
					grade: this.grade,
					type: 2,
					sid: this.sid,
					textbook: this.textboox,
					page: 1,
					pagesize: 99,
					fid: zid
				}
				// 请求[章节知识点列表](旧接口)
				this.$zapi.apiPost('user/subject.Lists/sectionList', data).then(res => {
					if (res.data.code == 200) {
						var listAll = res.data.data.data;

						// 存储所有章节id，以便作为参数传递
						var arr = [];
						listAll.forEach((item,index) =>{
							arr.push(item.zid)
						})
						
						// 请求[按章节筛选错题本(获取章节答题基本情况]
						this.$zapi.apiPost('user/intelligent.users/ScreenListsByzid', {
							zid: arr,
							student_id: this.student_id,
						}).then(res => {
							if (res.data.code == 200) {
								// 拿到每道题的错误状态，也就是错了多少道，以及他的章节id
								var data = res.data.data;
								
								// 存储错题的章节数据
								var arr1 = [];
								for (let i = 0; i < data.length; i++) {
									// 要有错题才可以进入循环
									if (data[i].errors_num > 0) {
										// 根据上次请求的章节id与现在反悔过来的章节进行循环判断，
										// 给上一个章节临时存储的listAll增加一个error_num属性
										for (var j = 0; j < listAll.length; j++) {
											if (data[i].zid == listAll[j].zid) {
												// 额外给listalll增加一个错误题数
												listAll[j].errors_num = data[i].errors_num;
												arr1.push(listAll[j]);
											}
										}
									}
								}
								// 存储循环判断后的数据，只有错题数据。
								_this.fList = arr1;
								var arr2 = [];
								// 根据错题章节ID再去请求对应的试题列表数据,需要循环请求
								for (var i = 0; i < _this.fList.length; i++) {
									let vData = {
										page: 1,
										pagesize: 1,
										zid: _this.fList[i].zid
									}
									let fList_ary = _this.fList[i];
									// 循环请求试题章节id对应的数据
									this.$zapi.apiPost('user/question.Lists/questionList', vData).then(res => {
										if (res.data.code == 200) {
											fList_ary['total'] = res.data.data.total;
											// 给每道错题加上一个总分
											arr2.push(fList_ary);
										}
									})
								}
								// 重新赋值
								_this.fList = arr2;
								// 累加每道题子章节列表的数据，并放到一个对象中，下次访问即可拿到对应的数据
								_this.zid_list[zid] = arr2
							}
						})
					}
				})
			},
			
			navClick(index) {
				if (index == 0) {
					this.typeIf = !this.typeIf;
					this.fromIf = false;
					this.methodIf = false;
				} else if (index == 1) {
					this.typeIf = false;
					this.fromIf = !this.fromIf;
					this.methodIf = false;
				} else if (index == 2) {
					this.typeIf = false;
					this.fromIf = false;
					this.methodIf = !this.methodIf;
				}
			},
			itemClick(name, id, index, navIndex, textboox) {
				this.show_loading = true
				if (navIndex == 0) {
					this.typeName = name;
					this.typeIf = false;
					this.itemIndex1 = index;
					this.page = 1;
					this.reload = true;
					this.question_typeid = id;
					this.sectionList = [];
					if (this.switch == 1) {
						this.switch = 0;
						this.itemIndex3 = 0;
						this.methodName = this.methodList[0].name;
						this.getSub();
						this.itemIndex4 = this.itemIndex4 + 1;
					}
					this.getlist();
				} else if (navIndex == 1) {
					this.fromName = name;
					this.fromIf = false;
					this.itemIndex2 = index;
					this.page = 1;
					this.reload = true;
					this.source_type = id;
					this.sectionList = [];
					if (this.switch == 1) {
						this.switch = 0;
						this.itemIndex3 = 0;
						this.methodName = this.methodList[0].name;
						this.getSub();
						this.itemIndex4 = this.itemIndex4 + 1;
					}
					this.getlist();
				} else if (navIndex == 2) {
					this.itemIndex3 = index;
					this.switch = index;
					this.methodName = name;
					// if(index == 2) {
					// 	this.methodName = '连对三次'
					// }
					this.datas = [];
					this.sectionList = [];
					this.getSub();
				} else if (navIndex == 3) {
					if (this.switch == 0) {  // 点击【按时间】会走进来
						this.subName = name;
						this.methodIf = false;
						this.itemIndex4 = index;
						this.page = 1;
						this.reload = true;
						this.sid = id;
						this.state = 1;
						this.sectionList = [];
						this.getlist();
					} else if (this.switch == 1) { // 点击【按章节】会走进来
						this.subName = name;
						this.methodIf = false;
						this.itemIndex4 = index;
						this.pages = 1;
						this.reload = true;
						this.sid = id;
						this.textboox = textboox;
						this.datas = [];
						this.itemIndex1 = 0;
						this.itemIndex2 = 0;
						this.typeName = this.typeList[0].question_type_name;
						this.fromName = this.fromList[0].title;
						this.getZjList();
					} else if (this.switch == 2) { // 点击【曾静的错题会走进来】
						this.subName = name;
						this.methodIf = false;
						this.itemIndex4 = index;
						this.page = 1;
						this.reload = true;
						this.sid = id;
						this.state = 3;
						this.sectionList = [];
						this.getlist();
					}
				}
			},

			// 跳转章节详情
			detail(intelligent_id) {
				uni.navigateTo({
					url: 'notes-detail?intelligent_id=' + intelligent_id + '&student_id=' + this.student_id + '&groupid=' + this.groupid
				})
			},

			// 跳转子章节详情
			changeZj(name, zid, fname, errors_num, total) {
				uni.navigateTo({
					url: 'notice-chapter?name=' + name + '&zid=' + zid + '&fname=' + fname + '&errors_num=' + errors_num + '&total=' +
						total + '&student_id=' + this.student_id + '&groupid=' + this.groupid
				})
			},

			// 移除错题
			detele(intelligent_id, index) {
				var _this = this;
				uni.showModal({
					content: '移除后将无法恢复，确定要移除错题吗？',
					confirmColor: '#FF9900',
					success(r) {
						if (r.confirm) {
							_this.$zapi.apiPost('user/intelligent.users/IntelligentRemove', {
								intelligent_id: intelligent_id
							}).then(res => {
								uni.showToast({
									title: res.data.msg,
									icon: 'none',
									success: function() {
										// TODO: 这里暂时不需要,并没有刷新
										// _this.getlist();
										// _this.$forceUpdate()
										// 直接从数组中删除
										_this.datas.splice(index, 1)
									}
								})

							})
						}
					}
				})
			},
			closeAll(){
				this.typeIf = false;
				this.fromIf = false;
				this.methodIf = false;
			},
		}
	}
</script>

<style>
	
	/* 年级弹窗样式 */
	/* 容器 */
	.wrap{
		position: fixed;
		width: 310upx;
		height: 400upx;
		right: 0;
		top: 10upx;
		z-index: 2;
		overflow: auto;
	}
	.wrap-grade{
		display: flex;
		position: absolute;
		width: 300upx;
		top: 16upx;
		right: 8upx;
		z-index: 2;
		flex-direction: column;
		border-radius: 10upx;
		background: #fff;
		color: #858585;
	}
	/* 三角形 */
	.wrap-grade:before{
		content: '';
		position: absolute;
		top: -16px;
		right: 15px;
		border-width: 10px;
		border-style: solid;
		border-color: transparent transparent white transparent;
	}
	/* 背景色 */
	.wrap-background{
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		z-index: 1;
		background-color: rgba(0, 0, 0, .5);
	}
	.grade-item{
		position: relative;
		padding-left: 20upx;
		padding: 20upx;
		border-bottom: 1px solid #e5e5e5;
	}
	.grade-item:last-child{
		border-bottom: none;
	}
	/* 打钩 */
	.dagou{
		position: absolute;
		right: 12upx;
		line-height: 1 !important;
	}
	/* 年级字体激活样式 */
	.grade_avctive {
		color: #FF9900;
	}
	
	page {
		background-color: #FAFAFA;
	}

	.content {
		width: 100%;
		height: 100%;
	}

	/**
	 * 选项卡
	 */
	.nav {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 88upx;
		line-height: 88upx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		background-color: #FFFFFF;
		border-bottom: 2upx solid #E5E5E5;
	}

	.nav_item1 {
		color: #333333;
		font-size: 34upx;
		width: 25%;
		height: 40upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0upx 2% 0upx 3%;
		border-right: 1upx solid #E5E5E5;
	}

	.nav_item2 {
		color: #333333;
		font-size: 34upx;
		width: 35%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0upx 2% 0upx 3%;
	}

	.nav_title {
		color: #333333;
		font-size: 34upx;
		line-height: 1;
	}

	.nav_icon {
		transform: rotate(90deg);
	}

	.nav_type {
		width: 100%;
		height: calc(100% - 88upx);
		background-color: rgba(0, 0, 0, 0.5);
		position: fixed;
		top: 88upx;
	}

	.type_item {
		display: flex;
		justify-content: space-between;
		background-color: #FFFFFF;
		height: 88upx;
		line-height: 88upx;
		padding: 0 40upx;
		color: #666666;
		font-size: 30upx;
		border-top: 2upx solid #E5E5E5;
	}

	.type_item2 {
		display: flex;
		justify-content: flex-start;
		background-color: #FAFAFA;
		max-height: 100%;
	}

	.name_active {
		color: #FF9900;
	}

	.type_active {
		background-color: #FAFAFA;
	}

	.iconduigou {
		line-height: 88upx;
		color: #FF9900;
	}

	.type_left {
		width: 200upx;
		background-color: #FFFFFF;
	}

	.type_right {
		width: calc(100% - 200upx);
	}

	.left_name {
		padding: 30upx 44upx;
		line-height: 40upx;
		border-bottom: 2upx solid #FAFAFA;
		color: #666666;
	}

	.right-subject {
		background-color: #FAFAFA;
		color: #666666;
		margin: 0 40upx;
		line-height: 88upx;
		display: flex;
		justify-content: space-between;
	}

	/* 列表 */
	.list {
		width: 100%;
		z-index: 1;
		margin: 100upx auto;
	}

	.list_item {
		background-color: #FFFFFF;
		margin-top: 12upx;
		margin-bottom: 10upx;
	}

	.question_classify {
		background: #00D5A2;
		color: #fff;
		text-align: center;
		border-radius: 0px 0px 6px 6px;
		width: 62upx;
		height: 32upx;
		line-height: 32upx;
		margin-left: 30upx;
		font-size: 26upx;
	}

	.title {
		color: #333333;
		font-size: 36upx;
		padding: 20upx 30upx;
	}

	.time {
		margin: 0 30upx;
		display: flex;
		justify-content: space-between;
		padding-bottom: 20upx;
	}

	.left {
		color: #999999;
		font-size: 30upx;
	}

	.time text {
		margin-left: 20upx;
	}

	.iconyichu {
		color: #FF9900;
		margin-right: 20upx;
		font-size: 40upx;
		line-height: 1.5;
	}

	.right {
		color: #FF9900;
		font-size: 30upx;
		display: flex;
	}

	/* 章节列表 */
	.zj-item {
		padding: 30upx;
		display: flex;
		justify-content: space-between;
	}

	.zj-item-name {
		color: #333333;
		font-size: 36upx;
		line-height: 1.2;
		width: 80%;
	}

	.dialog {
		width: 100%;
		background-color: #FFFFFF;
		border-top: 2upx solid #E5E5E5;
	}

	.dialog-item {
		margin: 0 30upx;
		padding: 30upx 0;
		border-bottom: 2upx solid #E5E5E5;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.dialog-item:last-child {
		border-bottom: none;
	}

	.dialog-item-left {
		max-width: 65%;
		color: #333333;
		font-size: 32upx;
		line-height: 1.2;
	}

	.dialog-item-right {
		display: flex;
		color: #CCCCCC;
		white-space: nowrap;
	}

	.dialog-item-right i {
		margin-left: 10upx;
	}

	.error1 text {
		color: #FF7171;
		margin-right: 8upx;
	}

	.error2 text {
		color: #00D5A2;
		margin-right: 8upx;
	}

	.rotate {
		transform: rotate(90deg);
	}

	.icon-fanhui {
		color: #999999;
	}

	.none {
		color: #999999;
		text-align: center;
		margin-top: 300upx;
		font-size: 36upx;
	}
</style>
